home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5971 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: memory allocation using malloc and free
  5. Date: 22 Feb 96 01:28:12 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.824952492@rscernix>
  8. References: <4gagll$5rc@bertrand.ccs.carleton.ca> <danpop.824767980@rscernix> <4gbqd7$1em@inet-nntp-gw-1.us.oracle.com> <4gd8ngINNp5i@keats.ugrad.cs.ubc.ca>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <4gd8ngINNp5i@keats.ugrad.cs.ubc.ca> c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
  13.  
  14. >In article <4gbqd7$1em@inet-nntp-gw-1.us.oracle.com>,
  15. >William Kaufman <wkaufman@wkaufman.us.oracle.com> wrote:
  16. > >In article <danpop.824767980@rscernix> danpop@mail.cern.ch (Dan Pop) writes:
  17. > >] In <4gagll$5rc@bertrand.ccs.carleton.ca> tcope@chat.carleton.ca (Tyler Cope) writes:
  18. > >] 
  19. > >] >Could someone please demonstrate the proper (or _a_ proper) ANSI
  20. > >] >method of allocating >64K space using malloc and free.
  21. > >[...]
  22. > >] 
  23. > >] The usual workaround on unextended MSDOS is to use vendor-specific
  24. > >] functions which take long or unsigned long arguments.  Of course, this
  25. > >] has nothing to do with ANSI C any longer.
  26. > >
  27. > >    One work-around which _is_ ANSI C would be to break the allocation
  28. > >down into a two-dimensional array where each dimension is less than 64K.
  29. > >The memory won't be continguous anymore, but this is often not a severe
  30. > >restriction.  And, it's portable.
  31.  
  32. It depends on what you mean by "portable".  ANSI doesn't even guarantee
  33. that you can get a single 64k block via malloc (or using static allocation).
  34.  
  35. >But can a compiler which restricts size_t to 16-bits a be a strictly conforming
  36. >implementation? (I don't have the standard documents yet, so I'm forced to
  37. >ask). 
  38.  
  39. Yes.
  40.  
  41. >If 16-bit size_t is admitted within the limitations of the standard, it
  42. >means that a strictly conforming program has to robustly accomodate itself on
  43. >such crippled architectures. I know that ANSI has some bottom limits on what
  44. >can be considered a viable architecture to host the C language, but what are
  45. >those limits?
  46.  
  47. For this particular discussion, the limit is 32K - 1.  And no more than
  48. one object of this size.  (Actually the phrasing is a little bit silly,
  49. because it doesn't even guarantee that every program containing such an
  50. object can be compiled and run, it requires that at least one program 
  51. should be correctly translated):
  52.  
  53.     2.2.4.1 Translation limits
  54.  
  55.     The implementation shall be able to translate and execute at least
  56.     one program that contains at least one instance of every one of the
  57.     following limits:
  58. ...
  59.      * 32767 bytes in an object (in a hosted environment only) 
  60.  
  61. Dan
  62. --
  63. Dan Pop
  64. CERN, CN Division
  65. Email: danpop@mail.cern.ch 
  66. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  67.